package me.ingxin.android.router;

import android.net.Uri;

import androidx.annotation.Nullable;

import me.ingxin.android.router.route.AnyLoader;
import me.ingxin.android.router.route.Request;
import me.ingxin.android.router.utils.Logger;

/**
 * Created by ingxin on 2022/4/28
 */
public class Router {

    /**
     * 构建路由跳转
     *
     * @param uri 需要跳转的目标路由
     */
    public static Request build(@Nullable String uri) {
        if (uri != null) {
            String decode = Uri.decode(uri);
            return new Request(Uri.parse(decode));
        } else {
            return new Request(Uri.EMPTY);
        }
    }

    /**
     * 获取路由对象
     *
     * @param uri 需要获取的路由地址
     */
    public static AnyLoader anyLoader(@Nullable String uri) {
        if (uri != null) {
            String decode = Uri.decode(uri);
            return new AnyLoader(Uri.parse(decode));
        } else {
            return new AnyLoader(Uri.EMPTY);
        }
    }

    public static void enableLog(boolean enable) {
        Logger.setEnableLog(enable);
    }

}
